package com.zeny.coding.controller.admin.business;


import com.zeny.coding.constants.CourseConstants;
import com.zeny.coding.dto.MemberDto;
import com.zeny.coding.dto.PageDto;
import com.zeny.coding.dto.Response;
import com.zeny.coding.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.bind.ValidationException;

/**
 * <h2>角色</h2>
 *
 * @Author Zeny
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("/business/admin/member")
public class MemberController {

    @Autowired
    private MemberService memberService;

    @PostMapping("/list")
    public Response list(@RequestBody PageDto<MemberDto> pageDto) {
        pageDto.check();
        memberService.list(pageDto);
        return new Response().success().data(pageDto).message(CourseConstants.QUERY_SUCCESS);
    }

    @PostMapping("/save")
    public Response save(@RequestBody MemberDto memberDto) throws ValidationException {
        memberDto.isValidForSave();
        this.memberService.save(memberDto);
        return new Response().success().message(CourseConstants.SAVE_SUCCESS);
    }
}
